﻿

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>字典管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="~/lib/layuiadmin/layui/css/layui.css" media="all">
	<link rel="stylesheet" href="~/lib/layuiadmin/style/admin.css" media="all">
</head>
<body>

	<div class="layui-fluid">
		<div class="layui-card">
			<div class="layui-form layui-card-header layuiadmin-card-header-auto">
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">字典名称</label>
						<div class="layui-input-block">
							<input type="text" name="id" placeholder="请输入名称" autocomplete="off" class="layui-input">
						</div>
					</div>
					@* <div class="layui-inline">
						<label class="layui-form-label">字典值</label>
						<div class="layui-input-block">
							<input type="text" name="id" placeholder="请输入值" autocomplete="off" class="layui-input">
						</div>
					</div> *@
				</div>
			</div>
			<div class="layui-card-body">
				<div style="padding-bottom: 10px;">
					@* <button class="layui-btn layuiadmin-btn-role" data-type="batchdel">删除</button> *@
					<button class="layui-btn layuiadmin-btn-role" data-type="add">添加一级</button>
					<button class="layui-btn layuiadmin-btn-role" data-type="add">添加二级</button>
				</div>

				<table class="layui-hide" id="test-table-radio" lay-filter="test-table-radio"></table>
				<script type="text/html" id="test-table-operate-barDemo">					
					<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
					<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
				</script>
			</div>
		</div>
	</div>

	<script src="~/lib/layuiadmin/layui/layui.js"></script>
	<script>
		layui.config({
			base: '/lib/layuiadmin/' //静态资源所在路径
		}).extend({
			index: 'lib/index' //主入口模块
		}).use(['index', 'table'], function () {
			var admin = layui.admin
				, table = layui.table;

			table.render({
				elem: '#test-table-radio'
				, url: layui.setter.base + '/json/table/user.js'
				, cellMinWidth: 80
				//, toolbar: '#test-table-radio-toolbarDemo'
				, cols: [[
					{ type: 'radio' }
					, { field: 'id', title: 'ID', sort: true }
					, { field: 'name', title: '字典名称' }
					, { field: 'parent', title: '父级字典'}
				]]
				, page: true
			});

			//头工具栏事件
			table.on('toolbar(test-table-radio)', function (obj) {
				var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
				switch (obj.event) {
					case 'getCheckData':
						var data = checkStatus.data;  //获取选中行数据
						layer.alert(JSON.stringify(data));
						break;
				};
				if (obj.event === 'del') {
					layer.confirm('真的删除行么', function (index) {
						obj.del();
						layer.close(index);
					});
				} else if (obj.event === 'edit') {
					layer.alert('编辑行：<br>' + JSON.stringify(data))
				}
			});

		});
	</script>
</body>
</html>

